/*============================================================================*/
/*  Copyright (C) 2009-2011, iSOFT INFRASTRUCTURE SOFTWARE CO.,LTD.
 *
 *  All rights reserved. This software is iSOFT property. Duplication
 *  or disclosure without iSOFT written authorization is prohibited.
 *
 *
 *  @file       <Com_Cbk.h>
 *  @brief      <Com Callback Function Declaration>
 *
 *  <Compiler: MinGW20120426    MCU:XXX>
 *
 *  @author     <Dongliang.Chen>
 *  @date       <22-04-2014>
 */
/*============================================================================*/
#ifndef  COM_CBK_H
#define  COM_CBK_H

/*=======[R E V I S I O N   H I S T O R Y]====================================*/
/*  <VERSION>    <DATE>    <AUTHOR>    <REVISION LOG>
 *  V1.0.0     20140217  Dongliang.Chen Initial version
 *                                      Add Requirements of AutoSAR Com 4.0 R1 As followed:
 *                                      COM578_Conf
 *                                      COM650, COM651, COM124, COM652, COM725, COM691, COM654,
 *                                      COM655, COM656, COM657, COM721, COM692, COM658, COM693,
 *                                      COM663
 */
/*============================================================================*/

/*=======[V E R S I O N  I N F O R M A T I O N]===============================*/
#define COM_CBK_H_AR_MAJOR_VERSION  3
#define COM_CBK_H_AR_MINOR_VERSION  2
#define COM_CBK_H_AR_PATCH_VERSION  0
#define COM_CBK_H_SW_MAJOR_VERSION  1
#define COM_CBK_H_SW_MINOR_VERSION  0
#define COM_CBK_H_SW_PATCH_VERSION  0

/*=======[I N C L U D E S]====================================================*/
#include "ComStack_Types.h"



/*=======[M A C R O S]========================================================*/



/*=======[T Y P E   D E F I N I T I O N S]====================================*/




/*=======[E X T E R N A L   D A T A]==========================================*/



/*=======[E X T E R N A L   F U N C T I O N   D E C L A R A T I O N S]========*/
/******************************************************************************/
/*
 * Brief               This function is called by the lower layer when an AUTOSAR
 *                     COM I-PDU shall be transmitted.
 * ServiceId           0x13
 * Sync/Async          Synchronous
 * Reentrancy          Non reentrant for the same PDU-ID. Reentrant for different PDU-ID.
 * Param-Name[in]      ComTxPduId: ID of AUTOSAR COM I-PDU that is requested to be
 *                                 transmitted by AUTOSAR COM.
 * Param-Name[out]     None
 * Param-Name[in/out]  PduInfoPtr: Contains a pointer to a buffer (SduDataPtr) to where
 *                                 the SDU shall be copied to. On return, the service
 *                                 will indicate the length of the copied SDU data in
 *                                 SduLength.
 * Return              Std_ReturnType:E_OK: SDU has been copied and SduLength indicates
                                            the number of copied bytes.
 *                                    E_NOT_OK: No SDU has been copied. SduLength has
 *                                              not been set.
 * PreCondition        None
 * CallByAPI           By Lower Layer
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(Std_ReturnType , COM_CODE)
Com_TriggerTransmit
(
    PduIdType ComTxPduId,
    CONSTP2VAR(PduInfoType, AUTOMATIC, COM_APPL_DATA) PduInfoPtr
);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"

/******************************************************************************/
/*
 * Brief               This function is called by the lower layer after an I-PDU
 *                     has been received.
 * ServiceId           0x14
 * Sync/Async          Synchronous
 * Reentrancy          Non reentrant for the same PDU-ID. Reentrant for different PDU-ID.
 * Param-Name[in]      ComRxPduId: ID of AUTOSAR COM I-PDU that has been received.
 *                                 Identifies the data that has been received.
 *                     PduInfoPtr: Contains the length (SduLength) of the received I-PDU
 *                                 and a pointer to a buffer (SduDataPtr) containing the
 *                                 I-PDU.
 * Param-Name[out]     None
 * Param-Name[in/out]  None
 * Return              None
 * PreCondition        None
 * CallByAPI           By Lower Layer
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(void, COM_CODE)
Com_RxIndication
(
    PduIdType ComRxPduId,
    P2CONST(PduInfoType, AUTOMATIC, COM_APPL_DATA) PduInfoPtr
);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"

/******************************************************************************/
/*
 * Brief               This function is called by the lower layer after the PDU
 *                     has been transmitted on the network.
 * ServiceId           0x15
 * Sync/Async          Synchronous
 * Reentrancy          Non reentrant for the same PDU-ID. Reentrant for different PDU-ID.
 * Param-Name[in]      ComTxPduId: ID of AUTOSAR COM I-PDU that has been transmitted.
 * Param-Name[out]     None
 * Param-Name[in/out]  None
 * Return              None
 * PreCondition        None
 * CallByAPI           By Lower Layer
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(void, COM_CODE)
Com_TxConfirmation(PduIdType ComTxPduId);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"

/******************************************************************************/
/*
 * Brief               By a call to Com_TpRxIndication the AUTOSAR COM module starts
 *                     the processing of the received large or dynamic length IPDU.
 * ServiceId           0x1e
 * Sync/Async          Synchronous
 * Reentrancy          Non reentrant for the same PDU-ID. Reentrant for different PDU-ID.
 * Param-Name[in]      PduId: ID of the AUTOSAR COM module's I-PDU that has been received.
 *                            Identifies the data that has been received.
 *                     Result: NTFRSLT_OK: the complete I-PDU has been received and is
 *                                         stored in the receive buffer.
 *                             <ANY OTHER VALUE>: the I-PDU has not been received; the
 *                                                receive buffer can be unlocked by the AUTOSAR
 *                                                COM.
 * Param-Name[out]     None
 * Param-Name[in/out]  None
 * Return              None
 * PreCondition        None
 * CallByAPI           By Lower Layer
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(void, COM_CODE)
Com_TpRxIndication(PduIdType PduId, NotifResultType Result);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"

/******************************************************************************/
/*
 * Brief               This function is called by the PduR after a large I-PDU has
 *                     been transmitted via the transport protocol on its network.
 * ServiceId           0x26
 * Sync/Async          Synchronous
 * Reentrancy          Non reentrant for the same PDU-ID. Reentrant for different PDU-ID.
 * Param-Name[in]      PduId: ID of the I-PDU that has been transmitted.
 *                     Result: Result of the transmission of the I-PDU.
 * Param-Name[out]     None
 * Param-Name[in/out]  None
 * Return              None
 * PreCondition        None
 * CallByAPI           By Lower Layer
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(void, COM_CODE)
Com_TpTxConfirmation(PduIdType PduId, NotifResultType Result);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"

/******************************************************************************/
/*
 * Brief               Com_StartOfReception returns the pointer to the size of the
 *                     AUTOSAR COM module's internal receive buffer for the I-PDU
 *                     with ID ComRxPduId.
 * ServiceId           0x25
 * Sync/Async          Synchronous
 * Reentrancy          Reentrant for different PduIds. Non reentrant for the same PduId.
 * Param-Name[in]      ComRxPduId: ID of Tp I-PDU to be received.
 *                     TpSduLength: complete length of the TP I-PDU to be received.
 * Param-Name[out]     RxBufferSizePtr: Pointer to the size of internal TP-receive buffer.
 * Param-Name[in/out]  None
 * Return              BufReq_ReturnType: BUFREQ_OK: Connection has been accepted.
 *                                                   RxBufferSizePtr indicates the available
 *                                                   receive buffer.
 *                                        BUFREQ_E_NOT_OK: Connection has been rejected.
 *                                                         RxBufferSizePtr remains unchanged.
 *                                                         In case the configured buffer size
 *                                                         as specified via PduIdRef.PduLength
 *                                                         is smaller than TpSduLength.
 * PreCondition        None
 * CallByAPI           By RTE
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(BufReq_ReturnType, COM_CODE)
Com_StartOfReception
(
    PduIdType ComRxPduId,
    PduLengthType TpSduLength,
    PduLengthType *RxBufferSizePtr
);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"

/******************************************************************************/
/*
 * Brief               Called once upon reception of each segment.
 * ServiceId           0x23
 * Sync/Async          Synchronous
 * Reentrancy          Reentrant for different PduIds. Non reentrant for the same PduId.
 * Param-Name[in]      PduId: ID of Tp I-PDU to be received.
 *                     PduInfoPointer: Pointer to a PduInfoType which indicates the number
 *                                     of bytes to be copied (SduLength) and the location of
 *                                     the source data (SduDataPtr).
 * Param-Name[out]     RxBufferSizePtr: Remaining receive buffer after completion of this call.
 * Param-Name[in/out]  None
 * Return              BufReq_ReturnType: BUFREQ_OK: Data has been copied to the receive buffer
 *                                                   completely as requested.
 *                                        BUFREQ_E_NOT_OK: Data has not been copied. Request failed.
 * PreCondition        None
 * CallByAPI           By RTE
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(BufReq_ReturnType, COM_CODE)
Com_CopyRxData
(
    PduIdType PduId,
    const PduInfoType *PduInfoPointer,
    PduLengthType *RxBufferSizePtr
);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"

/******************************************************************************/
/*
 * Brief               At invocation of Com_CopyTxData the AUTOSAR COM module copy
 *                     the re-quested transmit data of the large IPDU with ID PduId
 *                     from its internal transmit buffer to the location specified by
 *                     the PduInfoPtr.
 * ServiceId           0x24
 * Sync/Async          Synchronous
 * Reentrancy          Reentrant for different PduIds. Non reentrant for the same PduId.
 * Param-Name[in]      PduId: ID of Tp I-PDU to be transmitted.
 *                     PduInfoPointer: Pointer to a PduInfoType, which indicates the number
 *                                     of bytes to be copied (SduLength) and the location
 *                                     where the data have to be copied to (SduDataPtr).
 *                     RetryInfoPtr: If the transmitted TP I-PDU does not support the retry
 *                                   feature a NULL_PTR can be provided.
 * Param-Name[out]     TxDataCntPtr: Remaining Tx data after completion of this call.
 * Param-Name[in/out]  None
 * Return              BufReq_ReturnType: BUFREQ_OK: Data has been copied to the receive buffer
 *                                                   completely as requested.
 *                                        BUFREQ_E_NOT_OK: Data has not been copied. Request failed,
 *                                                         in case the corresponding I-PDU was stopped.
 * PreCondition        None
 * CallByAPI           By RTE
 */
/******************************************************************************/
#define COM_START_SEC_CODE
#include "Com_MemMap.h"
extern FUNC(BufReq_ReturnType, COM_CODE)
Com_CopyTxData
(
    PduIdType PduId,
    PduInfoType *PduInfoPtr,
    RetryInfoType *RetryInfoPtr,
    PduLengthType *TxDataCntPtr
);
#define COM_STOP_SEC_CODE
#include "Com_MemMap.h"




/*=======[I N T E R N A L   D A T A]==========================================*/



/*=======[I N T E R N A L   F U N C T I O N   D E C L A R A T I O N S]========*/



#endif  /* end of COM_CBK_H */

/*=======[E N D   O F   F I L E]==============================================*/

